package usermanager

import grails.converters.JSON

class ExtJsController {
	def extJsService
	def index = { }
	def updateData = {
		def responce = extJsService.updateData(params)
		if(responce.success==true) {
			render responce as JSON
		} else {
			[obj: responce.error]
		}
	}
	def createData = {
		def responce = extJsService.createData(params)
		if(responce.success==true) {
			render responce as JSON
		} else {
			[obj: responce.error]
		}
	}
		
	def deleteData = {
		if(params.node!=null)
			render extJsService.deleteData(params.node.split(" "))
	}

	def getJson = {
		if(params.node!=null)
			render extJsService.getTreeData(params.node.split(" ")) as JSON
		if(params.cell!=null)
			render extJsService.getInfoPanelData(params.cell.split(" ")) as JSON
    }
}